package top.yaofengqiao.springcloudsimple.payment.biz.trigger.job;

import cn.hutool.core.collection.CollUtil;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import top.yaofengqiao.springcloudsimple.payment.biz.domain.pay.model.entity.PaymentOrderEntity;
import top.yaofengqiao.springcloudsimple.payment.biz.domain.pay.service.IPaymentService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yfq
 * @date 2024/8/5 11:39
 * @description
 */
@Component
@EnableScheduling
public class PaymentOrderJob {
    @Resource
    private IPaymentService paymentService;

    // 定时任务处理调单补偿
    @Scheduled(cron = "*/1 * * * * ?")
    public void loseOrderCompensate() {
        long startId = -1;
        int limit = 100;

        List<PaymentOrderEntity> unPaymentOrders;
        do {
            unPaymentOrders = paymentService.queryUnPaymentOrder(startId, limit);

            for (PaymentOrderEntity unPaymentOrder : unPaymentOrders) {
                String payChannel = unPaymentOrder.getPayChannel();
//                if () {
//
//                }
            }

        } while (CollUtil.isEmpty(unPaymentOrders));

    }

}
